﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Text;
using System.IO;
using System.Xml;
using BLL;
using DAL;
using Models;
using System.Data;
using Web.Old_App_Code;
using System.Collections;


public partial class cn_points_for : System.Web.UI.Page
{
    // Fields
    protected PointsForManager pfm = new PointsForManager();
    protected PointsForOrderManager pfom = new PointsForOrderManager();

    // Methods
    protected string KeywordsBind()
    {
        string str = "";
        try
        {
            if (base.Request.QueryString["id"] == null)
            {
                return str;
            }
            DataTable pointsForById = this.pfm.GetPointsForById(Convert.ToInt32(base.Request.QueryString["id"]));
            if (pointsForById.Rows.Count > 0)
            {
                str = pointsForById.Rows[0]["name"].ToString();
            }
            if (str != "")
            {
                str = str + "，";
            }
            str = str + "积分兑换，";
        }
        catch
        {
        }
        return str;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected StringBuilder PointsForBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            builder.AppendLine("<div class=\"container exchange\">");
            builder.AppendLine("<h1>积分兑换区</h1>");
            builder.AppendLine("<div class=\"exchange_info\">");
            if (base.Request.QueryString["id"] != null)
            {
                DataTable pointsForById = this.pfm.GetPointsForById(Convert.ToInt32(base.Request.QueryString["id"]));
                if (pointsForById.Rows.Count > 0)
                {
                    DataRow row = pointsForById.Rows[0];
                    int countByPointsFor = this.pfom.GetCountByPointsFor(Convert.ToInt32(row["id"]));
                    builder.AppendLine("<div class=\"info\">");
                    builder.AppendLine(string.Concat(new object[] { "<div><img src=\"", row["image"], "\" alt=\"", row["name"], "\"/></div>" }));
                    builder.AppendLine("<h6>" + row["name"] + "</h6>");
                    builder.AppendLine(string.Concat(new object[] { "<span><input type=\"submit\" value=\"立即兑换\" onclick=\"pointsFor('", row["id"], "','", row["exchangePoints"], "');\" /></span>" }));
                    builder.AppendLine(string.Concat(new object[] { "<p><em>兑换次数:", countByPointsFor, "次</em>所需积分：<strong>", row["exchangePoints"], "</strong></p>" }));
                    builder.AppendLine("</div>");
                    builder.AppendLine("<div class=\"three\">");
                    builder.AppendLine("<p class=\"top_title\">参数</p>");
                    builder.AppendLine("<h4>" + row["name"] + "</h4>");
                    builder.AppendLine("<div class=\"exchage_content\">" + row["descript"] + "</div>");
                    builder.AppendLine("</div>");
                }
            }
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

}